#include "echoservice.h"

EchoService::EchoService()
{
}

QByteArray EchoService::execute (QDataStream &in)
{
    QByteArray block;
    QDataStream out(&block, QIODevice::WriteOnly);

    QString requestType;

    in >> requestType;

    if(requestType == "ECHO")
    {
        QString message;
        in >> message;

        out << quint16(0) << QString("RESULT") << message;
        out.device()->seek(0);
        out << quint16(block.size() - sizeof(quint16));
    }
    return block;
}
